;递归版本
(define (accumulate combiner custom-filter null-value term a next b)
  (cond ((> a b) null-value)
        ((custom-filter a) (combiner (term a) (accumulate combiner null-value (next a) next b))) 
        (else (accumulate combiner null-value (next a) next b))))

;迭代版本
(define (accumulate combiner custom-filter null-value term a next b)
  (define (product-iter a result)
    (cond ((> a b) result)
          ((custom-filter a) (product-iter (next a) (combiner result (term a))))
          (else (product-iter (next a) result))))
  (product-iter a null-value))
